home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_05 / test_obj / testgen.h < prev    next >
C/C++ Source or Header  |  1993-01-20  |  2KB  |  54 lines

  1. /* File:     Testgen.h
  2.    Copyright Norman Wilde 1993
  3.    Notes:
  4.    The Test_gen class provides facilities for generating successively
  5.    a series of integer vectors indicating
  6.    the combinations of parameter values to be used in a test run
  7.    The Test_gen_varying sub-class varies parameters one at a time,
  8.     leaving the others at their default (zeroith) value.
  9.    The Test_gen_combining sub-class generates all combinations of values.
  10.    Parameters:
  11.      num_params           is the number of parameters to be varied
  12.               and is the dimension of the vectors produced
  13.               0 < num_params
  14.      max_vals[num_params] is the number of values of each parameter,
  15.               0 < max_vals[i] < 20
  16.      test_vals[num_params] is the vector produced. If test_vals[2] = 3
  17.                           then the parameter takes on its 4th value.
  18.               0 <= test_vals[i] < max_vals[i]
  19.      Exceptions: If created or used with invalid values a warning is
  20.      written to stdout and no further vectors are generated. The
  21.      ok() member function may be used to check that a Test_gen is
  22.      available for use.
  23. */
  24. #include <iostream.h>        // to get ostream for the << operator
  25. enum MORETESTS { NO, YES};
  26. class Test_gen {
  27. protected:
  28.    int* max_vals; // array with number of values for each param
  29.    int num_params; // number of params
  30. public:
  31.    Test_gen(int num_params, int max_val[]);
  32.    ~Test_gen();
  33.    MORETESTS next_vector(int test_vals[]);
  34.    int ok(void);   // class invariant - use in assert statements
  35.    friend ostream& operator<< (ostream& s, Test_gen& t);
  36.       // output num_params and max_vals as text
  37. };
  38. class Test_gen_varying : public Test_gen {
  39.    int param_to_vary; // parameter currently being varied, -1 at beginning
  40.    int last_val; // last value of that parameter
  41. public:
  42.    Test_gen_varying(int num_params, int max_val[]);
  43.    MORETESTS next_vector(int test_vals[]);
  44.    int ok(void);
  45. };
  46. class Test_gen_combining : public Test_gen {
  47.    int *last_val; // last values of all parameters
  48. public:
  49.    Test_gen_combining(int num_params, int max_val[]);
  50.    ~Test_gen_combining();
  51.    MORETESTS next_vector(int test_vals[]);
  52.    int ok(void);
  53. } ;
  54.